package com.lmx.messagetemplate;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import com.lmx.messagetemplate.util.SharedPreUtil;

import org.litepal.LitePal;

public class App extends Application {

    private SQLiteDatabase database;
    private static volatile App mInstance;

    public static App getInstance() {
        if (mInstance == null) {
            synchronized (App.class) {
                if (mInstance == null) {
                    mInstance = new App();
                }
            }
        }
        return mInstance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mInstance = this;
        // 初始化共享首选项
        SharedPreUtil.getInstance(this, "data");
        // 初始化数据库
        LitePal.initialize(this);
        database = LitePal.getDatabase();
    }

    public SQLiteDatabase getDatabase() {
        return database;
    }
}
